package oa.web.controller;

import java.sql.Date;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import oa.biz.ActivityActorBiz;
import oa.biz.ActivityBiz;
import oa.entity.Activity;
import oa.entity.ActivityActor;
@RequestMapping("/admin")
@Controller
public class MettingController {
	@Autowired
	private ActivityBiz actbiz;
	@Autowired
	private ActivityActorBiz actorbiz;
	
	@RequestMapping("/mettingadd")
	public String mettingadd(){
		
		return "mettingadd";
	}
	@RequestMapping(value="/mettingsave",method=RequestMethod.POST)
	public String mettingsave(Model model,ActivityActor actor,Activity activity,@Param("actorId")String[]actorId){
		activity.setId(0);
		activity.setCreateTime(new Date(System.currentTimeMillis()));
		actbiz.addActivity(activity);
		actor.setId(0);
		actor.setActivityId(actbiz.selectaddId());
		for(int i=0;i<actorId.length;i++){
			actor.setActorId(Integer.parseInt(actorId[i]));
			actorbiz.addActivityActor(actor);
		}
		
		return "calendar";
	}
}
